package com.insurance.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang.StringUtils;

import java.util.List;

/**
 * token用户
 *
 * @author Style
 * @version 1.0
 * @date 2020/12/18
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class InsuranceUser {

    /**
     * 用户主键
     */
    private String userId;

    /**
     * 用户名
     */
    private String userName;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 用户类型
     */
    private String userType;

    /**
     * 证件类型
     */
    private String certificateType;

    /**
     * 证件号
     */
    private String certificateNo;

    /**
     * 来源
     */
    private String appId;

    /**
     * 角色
     */
    private List<String> roles;

    public InsuranceUser(AuthenticationUserEntity authenticationUserEntity) {
        this.userId = String.valueOf(authenticationUserEntity.getId());
        this.userName = StringUtils.isNotBlank(authenticationUserEntity.getUserName()) ? authenticationUserEntity.getUserName() : "";
        this.realName = StringUtils.isNotBlank(authenticationUserEntity.getRealName()) ? authenticationUserEntity.getRealName() : "";
        this.userType = StringUtils.isNotBlank(authenticationUserEntity.getUserType()) ? authenticationUserEntity.getUserType() : "";
        this.certificateNo = StringUtils.isNotBlank(authenticationUserEntity.getCertificateNo()) ? authenticationUserEntity.getCertificateNo() : "";
        this.certificateType = StringUtils.isNotBlank(authenticationUserEntity.getCertificateType()) ? authenticationUserEntity.getCertificateType() : "";
        this.appId = StringUtils.isNotBlank(authenticationUserEntity.getAppId()) ? authenticationUserEntity.getAppId() : "";
    }

}
